﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SQLiteProviderStack
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                

                ProfileBase profile;
                if (Request.IsAuthenticated)
                {
                    
                    profile = ProfileBase.Create(Page.User.Identity.Name, true);
                    DisplayNameLabel.Text = (string)profile.GetPropertyValue("DisplayName");
                }
                else
                {
                    profile = ProfileBase.Create(Page.Request.AnonymousID, false);
                    DisplayNameLabel.Text = "Guest";
                }

                profile["Counter"] = (int)profile["Counter"] + 1;
                profile.Save();

                CounterLabel.Text = ((int)profile["Counter"]).ToString();
            }

        }
    }
}
